﻿using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace YOLO4DMF {
    public partial class Form1 : Form {

        const string dll = "DLL.dll";

        [DllImport(dll, EntryPoint = "openVideo", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool openVideo(string path);

        [DllImport(dll, EntryPoint = "openCamera", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool openCamera(int index, double w, double h, double fps);

        [DllImport(dll, EntryPoint = "readFrame", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool readFrame(uint sleepTime = 1);

        [DllImport(dll, EntryPoint = "getResultImage", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool getResultImage(ref byte data, out ulong size);

        [DllImport(dll, EntryPoint = "drawCross", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool drawCross(uint x, uint y, uint radius, uint thickness);

        [DllImport(dll, EntryPoint = "getTransformMatrix", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool getTransformMatrix(ref uint anchors);

        [DllImport(dll, EntryPoint = "readLabelMatrix", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool readLabelMatrix(string path);

        [DllImport(dll, EntryPoint = "perspectiveTransform", CallingConvention = CallingConvention.Cdecl)]
        public static extern void perspectiveTransform();

        [DllImport(dll, EntryPoint = "loadYOLOModel", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool loadYOLOModel(string path);

        [DllImport(dll, EntryPoint = "setYOLOConfidence", CallingConvention = CallingConvention.Cdecl)]
        public static extern void setYOLOConfidence(float confidence);

        [DllImport(dll, EntryPoint = "setYOLONMSThreshold", CallingConvention = CallingConvention.Cdecl)]
        public static extern void setYOLONMSThreshold(float threshold);

        [DllImport(dll, EntryPoint = "detectDroplets", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool detectDroplets(out uint droplet_num);

        [DllImport(dll, EntryPoint = "initTracker", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool initTracker();

        [DllImport(dll, EntryPoint = "trackDroplets", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool trackDroplets(out uint droplet_num, ref uint results);

        [DllImport(dll, EntryPoint = "close", CallingConvention = CallingConvention.Cdecl)]
        public static extern void close(); // close camera or video
    }
}
